package com.lovo.game;

import javax.swing.*;

public class GuessGame {
    private Computer computer = new Computer();
    private Player player = new Player();
    public void run(){
        computer.generateNumbers();
        System.out.println(computer);
        for(int i = 0;i < 5;i++){
            player.generateNumbers();
            int a = 0;
            int b = 0;
            int [] computerNumbers = computer.getNumbers();
            int [] playerNumbers = player.getNumbers();
            for(int j = 0;j < computerNumbers.length;j++){
                for(int k = 0;k < playerNumbers.length;k++){
                    if(computerNumbers[j] == playerNumbers[k]){
                        if(j == k){
                            a++;
                        }else{
                            b++;
                        }
                    }
                }
            }
            System.out.println("结果："+a+"A"+b+"B");
            if(a == 4){
                System.out.println("恭喜你，猜对了");
                System.exit(0);
            }
        }
        System.out.println("垃圾");
    }
    public static void main(String[] args) {
//        Computer computer = new Computer();
//        computer.generateNumbers();
//        System.out.println(computer);
//
//        Player player = new Player();
//        player.generateNumbers();
//        System.out.println(player);
        GuessGame guessGame = new GuessGame();
        guessGame.run();
    }
}
